package main

import (
	"parking-lot-go-admin/config"
	"parking-lot-go-admin/middleware"
	"parking-lot-go-admin/router"
	"time"

	"github.com/gin-gonic/gin"
)

func main() {
	// 设置全局时区为 CST
	loc, err := time.LoadLocation("Asia/Shanghai")
	if err != nil {
		panic(err)
	}
	time.Local = loc

	r := gin.Default()

	r.Static("/uploads", "./uploads")

	//跨域请求中间件
	r.Use(middleware.CorsMiddleware())

	//无需登录
	router.NoLogin(r)

	//验证身份
	router.StartRoutes(r)

	// 读取配置文件
	dbSection := config.Cfg.Section("SYSTEM")

	port := dbSection.Key("PORT").String()

	r.Run(":" + port)
}
